<template>
	<Header :style="{padding: 0}" class="layout-header-bar" :data-i="$store.state.refresh">
		<!-- <Icon @click.native="collapsedSider" :class="rotateIcon" :style="{margin: '0 20px'}" type="md-menu" size="24"></Icon> -->
		<!-- <span style="margin-left: 20px" v-if="type == 2">
            <router-link to="/thelog/balance">账户余额：￥{{balance}}</router-link>
        </span> -->

<!-- 		<div style="float: left;color: #fff;margin-left: 200px;display: flex;align-items: center;">
			<span>演示权限：</span>
			<span>切换账号：</span>
			<span>
				<Select v-model="type" filterable @on-change="onChange">
					<Option value="1">admin</Option>
					<Option value="2">manager</Option>
					<Option value="3">operator</Option>
				</Select>
			</span>
			
			<template v-if="type == 1">
				<span style="margin-left: 10px;">
					(菜单权限: all)
				</span>
				<span style="margin-left: 20px;">
					(按钮权限: all)
				</span>
			</template>
			<template v-if="type == 2">
				<span style="margin-left: 10px;">
					(菜单权限: 首页，账号管理，设备管理)
				</span>
				<span style="margin-left: 20px;">
					(按钮权限: 设备编辑、添加、删除，所属机器组、操作员)
				</span>
			</template>
			<template v-if="type == 3">
				<span style="margin-left: 10px;">
					(菜单权限: 首页，账号管理)
				</span>
				<span style="margin-left: 20px;">
					(按钮权限: 查看)
				</span>
			</template>

		</div> -->


		<Dropdown style="float:right;margin-right: 20px" placement="top-end" @on-click="DropdownItem ">
			<a href="javascript:void(0)">
				欢迎您，{{name}}
				<Icon type="ios-arrow-down"></Icon>
			</a>
			<DropdownMenu slot="list">
				<!-- <DropdownItem name="password"><router-link style="color: initial;" to="/system/password">修改密码</router-link></DropdownItem> -->
				<DropdownItem name="logout">退出登录</DropdownItem>
			</DropdownMenu>
		</Dropdown>
	</Header>

</template>
<script>
	export default {
		data() {
			return {
				type: '1',
				name: '',
				balance: ''
			}
		},
		inject:['reload'],
		created() {
			this.info()
		},
		methods: {
			DropdownItem(name) {
				if (name === 'logout') {
					// this.astgo.removeItem('token');
					// this.astgo.removeItem('refer');
					// this.astgo.removeItem('type');
					this.astgo.removeItem(this.Pn + "info");
					this.$Message.error('退出登录!');
					this.$router.push('/login');
				}
			},
			info() {
				this.name =JSON.parse(this.astgo.getItem(this.Pn + "info")).username;
			},
			onChange(e){
				console.log(e)
				this.type = e;
				if(e == 1){
					this.name = 'admin'
					this.$store.commit('setBreadcrumb',['1','2','3','4'])
					this.$store.commit('setMenu',true)
				}else{
					this.name = 'manager'
					this.$store.commit('setBreadcrumb',[])
					this.$store.commit('setMenu',false)
				}
				
				this.reload()
				
				// console.log(this.$store.state.Breadcrumb)
				console.log(this.$store.state.menuList)
				
			},

		},
		watch: {
			$route(to, form) {

				// this.name = this.astgo.getItem('name');
				
				this.name =JSON.parse(this.astgo.getItem(this.Pn + "info")).username;	
				
				console.log(JSON.parse(this.astgo.getItem(this.Pn + "info")))
				
				// this.type = this.astgo.getItem('type');

				// this.name = 'admin';
				// this.type = 1;

			}
		}
	}
</script>
<style lang="scss" scoped>

</style>
